﻿using Sunny.UI;
using System.Collections.Generic;
using CoreShop.Model;
using CoreShop.Services;
using System;
using CoreShop.Model.UI;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Collections;
using System.Security.Policy;
using SqlSugar.Extensions;
using Sunny.UI.Win32;
using System.Windows.Forms;
using System.ComponentModel;
using CoreShop.Library;
using System.Data;
using FastMember;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System.IO;
using Loading;
using CoreShop.App.Units.Interface;
using System.Threading.Tasks;
using static CoreShop.Model.FromBody.DataResultModel;
using NPOI.SS.Formula.Functions;

namespace CoreShop.App
{
    public partial class frmGoodsChgPrice : UIForm
    {
        public bool returnValue;
        OpaqueCommand cmd = new OpaqueCommand();
        public int mPageIndex = 0;
        public string number = "";

        public frmGoodsChgPrice()
        {
            InitializeComponent();
            this.dgvMemberList.AutoGenerateColumns = false;
        }

        #region 加载信息列表
        private void LoadDataList()
        {
            btnPg.PageSize = 20;
            cmd.ShowOpaqueLayer(pnl_Form, 125, true);
            try 
            {
                int count = 0;
                var dataList = new corecmschgpriceServices().QueryPageAsync(ref count, mPageIndex, btnPg.PageSize, txtSearch.Text,CommFunc.ConvertToDateTime(billDate.Text));
                btnPg.TotalCount = count;
                this.dgvMemberList.DataSource = dataList;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cmd.HideOpaqueLayer();
            }
        }
        #endregion
        
        private void FMember_Load(object sender, System.EventArgs e)
        {
            billDate.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            this.ShowFullScreen = AppConstVars.showFullScreen;
            mPageIndex = 1;
            LoadDataList();
        }


        private void btnSerach_Click(object sender, EventArgs e)
        {
            mPageIndex = 1;
            LoadDataList();
        }


        private void tv_usercategory_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LoadDataList();
        }

        private void btnPg_PageChangedAsync(object sender, object pagingSource, int pageIndex, int count)
        {
            mPageIndex = pageIndex;
            LoadDataList();
        }

        private void txtSearch_OkButtonClick(object sender, string value)
        {
            btnSerach_Click(null, null);
        }

        private void txtSearch_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13) btnSerach_Click(null,null);
        }

        public void btnPg_PageChanged(object sender, object pagingSource, int pageIndex, int count)
        {
            mPageIndex = pageIndex;
            LoadDataList();
        }
    }
}